xen: arm: Avoid reading beyond the last module
authorChris (Christopher) Brand <chris.brand@broadcom.com>
Fri, 17 Jul 2015 20:48:08 +0000 (20:48 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 21 Jul 2015 14:08:07 +0000 (15:08 +0100)
commit04425e40b427d9f0469d9db9321839d434a3580b
tree92f572596ebbf915e538fe42044229409e9bd34e
parent2eb3a43b2e6e08582667ad302e8ec5a7d5897611
xen: arm: Avoid reading beyond the last module

nr_mods is set in add_boot_module() to the number of module
array elements used. This function also ensures that nr_mods
never exceeds MAX_MODULES (the size of the array). When looping
through the array, the correct maximum index is "nr_mods-1",
not "nr_mods". If the array is full, using the latter will in
fact access beyond the end of the array.
This was done correctly in boot_module_find_by_kind() and
consider_modules() but incorrectly in discard_initial_modules()
and next_module().

Signed-off-by: Chris Brand <chris.brand@broadcom.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/setup.c